<?php
class ReturnDelAction extends UserAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'tpl';
		$this->layout = 'index';
	}

	public function execute()
	{
		$returnService	= new ReturnService();
		$id				= $this->context->get('id');
		if(is_numeric($id) && $id)
		{
			$info		= $returnService->get($id);
			if($info && $info['user_id']==$this->data['user']['id'] && $info['status']!=1)
			{
				if(C('UserService')->addMoney($info['user_id'],$info['money']))
				{
					$returnService->del($id);
				}
			}
		}
		header('Location:'.$this->context->referer(C('Lturl')->generate('Return', 'Index')));
	}
}
